package com.chenzhou.product_sys.service;

import com.chenzhou.product_sys.dao.impl.GoodsDAOImpl;
import com.chenzhou.product_sys.entity.GoodsEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsService {

    @Autowired
    private GoodsDAOImpl dao;

    public List<GoodsEntity> queryAllGoods(){
        return dao.queryAllGoods();
    }

    public GoodsEntity queryGoodsByID(Integer id){
        return dao.queryGoodsByID(id);
    }

    public int add_Goods(GoodsEntity goodsEntity){
        return dao.add_GoodsEntity(goodsEntity);
    }

    public int modify_Goods(GoodsEntity goodsEntity){
        return dao.update_GoodsEntity(goodsEntity);
    }

    /***
     * 删除业务思路
     * 当你删除一条商品信息，附带要删除图片表中和商品关联的图片信息
     * @param id
     * @return
     */
    public int delete_Goods(Integer id){
        ///TODO 删除商品信息，要附带删除商品的图片资源
        return dao.delete_GoodsEntity(id);
    }
}
